#include <iostream>
#include <string>
#include "Log.hpp"
#include "Listener.hpp"
#include "Connection.hpp"
#include "Reactor.hpp"

using namespace LogMudule;

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cout << "Usage: " << argv[0] << " port" << std::endl;
        return 1;
    }
    ENABLE_CONSOLE_LOG();
    uint16_t local_port = std::stoi(argv[1]); // 端口号

    auto conn = std::make_shared<Listener>(local_port); // 构建Listener、Connection对象
    
    Reactor reactor;
    // 创建epoll模型
    reactor.Init();

    reactor.InsertConnection(conn);
    // 循环监控
    reactor.Loop();
    return 0;
}